package com.lrl.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        /*页面映射*/

        /*首页映射*/
        registry.addViewController("/").setViewName("index");
        registry.addViewController("/admin").setViewName("index");
        registry.addViewController("/admin/main.html").setViewName("index");
        registry.addViewController("/admin/index.html").setViewName("index");

        /*登录映射*/
        registry.addViewController("/admin/login.html").setViewName("login");

    }

    //构建一个局部语言解析器
    @Bean
    public LocaleResolver localeResolver() {
        return new MyLocaleResolver();
    }

}
